import { CoolController, BaseController } from '@cool-midway/core';
import { Body, Inject, Post } from '@midwayjs/core';
import { Validate } from '@midwayjs/validate';
import { RouterService } from '../../service/router/router';
import { GradeDTO } from '../../dto/grade';

/**
 * 考试
 */
@CoolController()
export class ExamController extends BaseController {
    @Inject()
    RouterService: RouterService;

    /**
     * 考试查询
     * @param year 学年
     * @param term 学期
     */
    @Post('/exam', { summary: '考试查询' })
    @Validate()
    async get_exam(@Body() params: GradeDTO) {
        const { year, term } = params;
        const { success, message, data } = await this.RouterService.get_exam(year, term);
        if (!success) return this.fail(data, message);
        return this.ok(data, message);
    }
}
